package com.guashu.springbootdistributedid.demo;

import java.util.Arrays;
import java.util.List;

public class test1 {
    public static void main(String[] args) {

        List<Integer> list = Arrays.asList(1, 0, 0, 1, 0,0,1,0);
        System.out.println(calculateConsecutiveOnes(list));
    }

    public static int calculateConsecutiveOnes(List<Integer> list) {
        int maxConsecutiveOnes = 0;
        int currentConsecutiveOnes = 0;

        for (Integer num : list) {
            if (num > 0) {
                currentConsecutiveOnes++;
                maxConsecutiveOnes = Math.max(maxConsecutiveOnes, currentConsecutiveOnes);
            } else {
                currentConsecutiveOnes = 0;
            }
        }

        return maxConsecutiveOnes;
    }
}
